using UnityEngine;
using System.Collections;
using System.Collections.Generic;

namespace KeyBindings
{
/// <summary>
/// The Bound key is for storing and linking keys to keywords used in the project
/// </summary>
	public class BoundKey
	{
		private static int numberOfKeys = 0;
		private KeyCode mappedKey;
		private bool held;

		/// <summary>
		/// Initializes a new instance of the <see cref="BoundKey"/> class.
		/// </summary>
		/// <param name="mappedKey">Mapped key.</param>
		public BoundKey (KeyCode mappedKey)
		{
			this.mappedKey = mappedKey;
			held = false;
		}

		~BoundKey ()
		{
			//Removes and destroied keys
			numberOfKeys--;
		}


		/// <summary>
		/// Gets or sets the mapped key.
		/// </summary>
		/// <value>The mapped key.</value>
		public KeyCode MappedKey {
			get {
				return mappedKey;
			}
			set {
				mappedKey = value;
			}
		}

		/// <summary>
		/// Sets a value indicating whether this <see cref="BoundKey"/> set held.
		/// </summary>
		/// <value><c>true</c> sets if the button is held; if not, <c>false</c>.</value>
		public bool setHeld {
			set {
				held = value;
			}
		}

		/// <summary>
		/// Is the key down.
		/// </summary>
		/// <returns><c>true</c>, if the key is down, <c>false</c> otherwise.</returns>
		public bool isDown ()
		{
			return held;
		}

		/// <summary>
		/// Gets the number of keys.
		/// </summary>
		/// <value>The number of keys.</value>
		public static int NumberOfKeys {
			get {
				return numberOfKeys;
			}
			set {
				numberOfKeys = value;
			}
		}
	
		/// <summary>
		/// String for the key [BoundKey: MappedKey=KeyCode, isDown=Boolean].
		/// </summary>
		/// <returns>A <see cref="System.String"/> that represents the current <see cref="BoundKey"/>.</returns>
		public override string ToString ()
		{
			return string.Format ("[BoundKey: MappedKey={0}, isDown={1}]", MappedKey.ToString (), held);
		}
	}
}

